function executeLoginJS(r){

	configureLoginLayer(r);

	var getRegisterForm = function()
	{
        showLoadingLayer();
		var responseFunction = function(response)
		{
			hideLoadingLayer();
		    response = JSON.parse(response);

		    if(response.htmlString && !response.htmlString.trim() == "")
		    {
		    	configureLoginLayer(response);
                debugger;
		    	initializeRegisterForm();
		    }
		};
		var url = getURL("register.php");
		$.post(url, {} ,responseFunction);
	};
    $("#loginRegisterLink").on("click", getRegisterForm);

    $("#loginPanel > form").on("submit", dontSubmit);
    debugger;
    $("#loginPanel form[name='login']").on("submit", dontSubmit);
    $("#loginPanel form[name='login'] input[type='submit']").on("click", doLogin);
}

function doLogin(){
        var id = $("#user_id").val();
        var pw = $("#user_pw").val();
        var params = {
            id : id,
            pw : pw,
            action : "login"
        };
        var url = getURL("accountValidator.php");
        showLoadingLayer();
        var responseFunction = function(r){
            hideLoadingLayer();
            r = JSON.parse(r);
            if(!r){
                alert("There was an error while logging in. Please try again.");
                return;
            }
            if(r.error){
                alert(r.response);
            }else{
                hideLoginLayer();
                var logoutFunction = function()
                {
                    $("#loginButton").on("click", doLogin);
                    var params = {action : "logout"};
                    var url = getURL("accountValidator.php");
                    $.post(url, params, function(){location.reload();});
                };
                $("#loginButton").html("LOGOUT");
                $("#loginButton").off("click").on("click", logoutFunction);
                addGoToProfile();
                $("#profileButton").trigger("click");
            }
        };
        debugger;
        $.post(url, params, responseFunction);
    };

function showProfieAndLogoutButtons(){
    var logoutFunction = function()
    {
        $("#loginButton").on("click", doLogin);
        var params = {action : "logout"};
        var url = getURL("accountValidator.php");
        $.post(url, params, function(){location.reload();});
    };
    $("#loginButton").html("LOGOUT");
    $("#loginButton").off("click").on("click", logoutFunction);
    addGoToProfile();
}